package com.jlu.test.doc;

import org.apache.http.HttpHost;
import org.elasticsearch.action.delete.DeleteRequest;
import org.elasticsearch.action.delete.DeleteResponse;
import org.elasticsearch.action.get.GetRequest;
import org.elasticsearch.action.get.GetResponse;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;

import java.io.IOException;

public class ESTest_Delete {

  public static void main(String[] args) throws IOException {

//    创建es客户端
    RestHighLevelClient client = new RestHighLevelClient(
            RestClient.builder(new HttpHost("localhost",9200, "http"))
    );

//    删除数据
    DeleteRequest request = new DeleteRequest();
    request.index("user").id("1001");

    DeleteResponse response = client.delete(request, RequestOptions.DEFAULT);

    System.out.println(response.toString());

//    关闭es客户端
    client.close();
  }
}
